package co.com.inventarios.persistencia;

import java.util.List;
import java.util.logging.Level;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import co.com.inventarios.modelo.Mngmcnsn;
import co.com.inventarios.modelo.Proserie;

public class QueryProserieDAO {

	private EntityManager getEntityManager() {
		return EntityManagerHelper.getEntityManager();
	}
	
	
	public List<Proserie> findByPropertySerie(String propertyName, String value ,String espresion) {

		EntityManagerHelper.log("finding Proserie instance with property: "
				+ propertyName + ", value: " + value, Level.INFO, null);
		try {
			//getEntityManager().clear();
			final String queryString = "select model from Proserie model where model.producto.procodigo = '"
					+ propertyName + "'  and model.id.psnserial = '" + value+ "'  and  model.psnexiste > 0  ";
			Query query = getEntityManager().createQuery(queryString);

			return query.getResultList();
		} catch (RuntimeException re) {
			EntityManagerHelper.log("find by property name failed",
					Level.SEVERE, re);
			throw re;
		}
	}
	
	
	
	
}
